CC = aarch64-openwrt-linux-gcc
#CC = /opt/powereuler/oecore-x86_64/sysroots/x86_64-peesdk-linux/usr/bin/aarch64-powereuler-linux-gcc
#CC = aarch64-powereuler-linux-gcc

#CC = /home/gcc/sysroots/x86_64-peesdk-linux/usr/bin/aarch64-powereuler-linux-gcc
#CC = gcc
CCFLAGS = -g -lrt
CXXFLAGS = -O2 -g -Wall -fmessage-length=0 -std=c++11

SOURCES = $(wildcard ./main/*.c ./src/*.c ./sdk/Api/configUp.c ./bridge_sdk/server_src/*.c)
#SOURCES = $(wildcard ./main/*.c ./src/*.c ./webModule/*.c)
#OBJS = SmartProbe.o ctrl.o log.o iniparser.o dictionary.o common.o mqttClient.o
OBJS = $(SOURCES:.c=.o)

HEADER_PATH = -I./include -I./include/json  -I./tools/libeagle_eye_tool -I./include/uv -I./sdk/Api -I./bridge_sdk/include
LIB_PATH = -L./lib
SRC_PATH = ./main
LIB_SET = -Wl,-rpath="./lib"
#LIBS = $(LIB_PATH) $(LIB_SET) -lpaho-mqtt3as -lcjson -lzlog -lsqlite3 -lfile_encrypt -lpthread -lcurl -lm -lssl -lcrypto
#LIBS = $(LIB_PATH) $(LIB_SET) -lpaho-mqtt3as -lcjson -lzlog -lsqlite3 -lfile_encrypt -lpthread -lcurl -lm -lssl -lcrypto -luv -lpcre2-8 -lcollector 
LIBS = $(LIB_PATH) $(LIB_SET) -lpaho-mqtt3as -lcjson -lzlog -lsqlite3 -lfile_encrypt -lpthread -lcurl -lm -lssl -lcrypto -luv
#要支持子设备接入就用下面的库
#LIB_PATH = -L./lib_tq_sd
#LIBS = $(LIB_PATH) $(LIB_SET) -lcjson -lzlog -lsqlite3 -lfile_encrypt -lpthread -lcurl -lm -lssl -lcrypto -luv -lpcre2-8 -lcollector -lnng -lsdf_crypto -lcn_x509_common -lcn_x509_crypto -lcn_x509_proxy
ifeq ($(CC),gcc)
	LIBS += -lrpm -lrpmio
endif


ifeq ($(OS), Windows_NT)
	TARGET = MQTT_Demo.exe
else 
	TARGET = EagleEyeSMG
endif

$(TARGET):	$(OBJS)
	echo "test"
	#cd ../build && cmake . && make
	#make && cd ..
	#make -C ../build
	$(CC) $(CCFLAGS) -o $(TARGET) $(OBJS) $(LIBS)

#%.o: $(SRC_PATH)/%.c
%.o: %.c
	$(CC) $(CCFLAGS) -c  -o $@ $< $(HEADER_PATH) #-std=c99 
	
all:	
	$(TARGET)

clean:
	#make clean -C ../build
	rm -f $(OBJS) $(TARGET)
	rm -f ./bridge_sdk/server_src/*.o
